package day13;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public
class Server {
    public static
    void main(String[] args) throws IOException {
        //创建服务器端的ServerSocket对象
        ServerSocket server=new ServerSocket(60000);
        while (true) {//控制多人连接
            Socket client=server.accept();//阻塞式方法  等待客户端连接
            System.out.println(client);
            //3.获取输入输出流(读取客户端发送的数据，向客户端发送数据)
            InputStream is=client.getInputStream();
            OutputStream os=client.getOutputStream();
            String msg="你好，我是服务器\n";
            os.write(msg.getBytes());

            BufferedReader br=new BufferedReader(new InputStreamReader(is));
            String str=br.readLine();
            System.out.println("客户端数据："+str);
        }
    }
}
